<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>订单管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出订单管理数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/crab/order/export");
						$("#searchForm").submit();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
			$("#btnImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/crab/order/list");
			$("#searchForm").submit();
        	return false;
        }
		function clearForm(){
			$("#orderNum").val('');
			$("#state").val('');
			$("#numStart").val('');
			$("#numEnd").val('');
			$("#mobile").val('');
			$("#startDate").val('');
			$("#endDate").val('');
			$("#searchForm").attr("action","${ctx}/crab/order/list");
			$("#searchForm").submit();
        	return false;
		}
	</script>
</head>
<body>
	<shiro:hasPermission name="crab:order:edit">
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/crab/order/import" method="post" enctype="multipart/form-data"
			class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
			<a href="${ctx}/crab/order/import/template">下载模板</a>
		</form>
	</div>
	</shiro:hasPermission>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/crab/order/">订单管理列表</a></li>
		<%-- <shiro:hasPermission name="crab:order:edit"><li><a href="${ctx}/crab/order/form">订单管理添加</a></li></shiro:hasPermission> --%>
	</ul>
	<shiro:hasPermission name="crab:order:edit">
	<form:form id="searchForm" modelAttribute="order" action="${ctx}/crab/order/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}" callback="page();"/>
		<ul class="ul-form">
			<li><label>订单号：</label>
				<form:input path="orderNum" htmlEscape="false" maxlength="32" class="input-medium"/>
			</li>
			<li><label>状态：</label>
				<form:select path="state" class="input-medium">
					<form:option value="">全部</form:option>
					<form:option value="0">未发货</form:option>
					<form:option value="1">已发货</form:option>
					<%-- <form:option value="2">已完成</form:option> --%>
				</form:select>
			</li>
			<li><label>手机号：</label>
				<form:input path="mobile" htmlEscape="false" maxlength="16" class="input-medium"/>
			</li>
			<li class="clearfix"></li>
		</ul>
		<ul class="ul-form">
			<li><label>兑换券卡号：</label>
				<form:input path="numStart" class="input-medium"/>至
				<form:input path="numEnd" class="input-medium"/>
			</li>
			
			<li><label>期望发货日：</label>
				<input name="startDate" id="startDate" type="text"  maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${order.startDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>至<input name="endDate" id="endDate" type="text"  maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${order.endDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();"/></li>
			<li class="btns"><input id="btnClear" class="btn btn-primary" type="button" onclick="clearForm()" value="重置"/></li>
			<li class="btns"><input id="btnExport" class="btn btn-primary" type="button" value="导出"/></li>
			<li class="btns"><input id="btnImport" class="btn btn-primary" type="button" value="导入"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	</shiro:hasPermission>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>订单号</th>
				<th>兑换券卡号</th>
				<th>密码</th>
				<th>商品名称</th>
				<th>订单生成日期</th>
				<th>收件人姓名</th>
				<th>收件人电话</th>
				<th>收件人地址</th>
				<th>期望发货日期</th>
				<th>备注</th>
				<th>状态</th>
				<th>信息发送状态</th>
				<th>分公司</th>
				<th>快递单号</th>
				<th>快递公司</th>
				<shiro:hasPermission name="crab:order:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="order">
			<tr>
				<td>
					${order.orderNum}
				</td>
				<td>
					${order.cardNum}
				</td>
				<td>
					${order.password}
				</td>
				<td>
					${order.productName}
				</td>
				<td>
					<fmt:formatDate value="${order.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${order.name}
				</td>
				<td>
					${order.mobile}
				</td>
				<td>
					${order.address}
				</td>
				<td>
					<fmt:formatDate value="${order.hopeDate}" pattern="yyyy-MM-dd"/>
				</td>
				<td>
					${order.remarks}
				</td>
				<td>
					<c:if test="${order.state==0}">未发货</c:if>
					<c:if test="${order.state==1}">已发货</c:if>
				</td>
				<td>
					<c:if test="${order.msgState==0}">未发送</c:if>
					<c:if test="${order.msgState==1}">发送成功</c:if>
					<c:if test="${order.msgState==2}">发送失败</c:if>
				</td>
				<td>
					${order.companyName}
				</td>
				<td>
					${order.expressNum}
				</td>
				<td>
					${order.expressCompany}
				</td>
				<shiro:hasPermission name="crab:order:edit"><td>
					<shiro:hasPermission name="crab:order:orderLogisticsForm">
					<a href="${ctx}/crab/order/orderLogisticsForm?id=${order.id}">物流信息</a>
					</shiro:hasPermission>
					<shiro:hasPermission name="crab:order:edit">
    				<c:if test="${order.state==0}"><a href="${ctx}/crab/order/form?id=${order.id}">修改</a></c:if>
    				</shiro:hasPermission>
    				<shiro:hasPermission name="crab:order:delete">
					<a href="${ctx}/crab/order/delete?id=${order.id}" onclick="return confirmx('确认要删除该订单管理吗？', this.href)">删除</a>
					</shiro:hasPermission>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>